import { Controller, Get, Post, Body, Patch, Param, Delete, Query } from '@nestjs/common';
import { ProductService } from './product.service';
import { CreateProductDto } from './dto/create-product.dto';
import { UpdateProductDto } from './dto/update-product.dto';
import { ProductQueryDto } from './dto/product-query.dto';

@Controller('product')
export class ProductController {
  constructor(private readonly productService: ProductService) {}

  @Post('create')
  create(@Body() createProductDto: CreateProductDto) {
    return this.productService.create(createProductDto);
  }

  @Get('list')
  findAll(@Query() productQueryDto: ProductQueryDto ) {
    return this.productService.findAll(productQueryDto);
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.productService.findOne(+id);
  }

  @Post('update')
  update( @Body() updateProductDto: UpdateProductDto) {
    return this.productService.update(updateProductDto);
  }

  @Post('delete')
  remove(@Body('id') id: string) {
    return this.productService.remove(id);
  }
}
